#include "clickeventfilter.h"

#include <QContextMenuEvent>

ClickEventFilter::ClickEventFilter(QObject *parent) : QObject(parent)
{

}

bool ClickEventFilter::eventFilter(QObject *obj, QEvent *event)
{
    if (event->type() == QEvent::MouseButtonPress) {
       QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
       if (mouseEvent->button() == Qt::LeftButton) {
           emit clicked();
           return true;  // 拦截事件，防止继续传递给部件
       }
    }

    return QObject::eventFilter(obj, event);
}
